Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports Microsoft.ApplicationBlocks.Data
Imports DotNetNuke.Common.Utilities
Namespace DotNetNuke.Modules.ActiveForums

    Public Class SqlDataProvider

        Inherits DataProvider

#Region "Private Members"

        Private Const ProviderType As String = "data"

        Private _providerConfiguration As DotNetNuke.Framework.Providers.ProviderConfiguration = DotNetNuke.Framework.Providers.ProviderConfiguration.GetProviderConfiguration(ProviderType)
        Private _connectionString As String
        Private _providerPath As String
        Private _objectQualifier As String
        Private _databaseOwner As String

#End Region

#Region "Constructors"

        Public Sub New()

            ' Read the configuration specific information for this provider
            Dim objProvider As DotNetNuke.Framework.Providers.Provider = CType(_providerConfiguration.Providers(_providerConfiguration.DefaultProvider), DotNetNuke.Framework.Providers.Provider)

            ' Read the attributes for this provider

            'Get Connection string from web.config
            _connectionString = Config.GetConnectionString()

            If _connectionString = "" Then
                ' Use connection string specified in provider
                _connectionString = objProvider.Attributes("connectionString")
            End If

            _providerPath = objProvider.Attributes("providerPath")

            _objectQualifier = objProvider.Attributes("objectQualifier")
            If _objectQualifier <> "" And _objectQualifier.EndsWith("_") = False Then
                _objectQualifier += "_"
            End If

            _databaseOwner = objProvider.Attributes("databaseOwner")
            If _databaseOwner <> "" And _databaseOwner.EndsWith(".") = False Then
                _databaseOwner += "."
            End If

        End Sub
#End Region

#Region "Properties"

        Public ReadOnly Property ConnectionString() As String
            Get
                Return _connectionString
            End Get
        End Property

        Public ReadOnly Property ProviderPath() As String
            Get
                Return _providerPath
            End Get
        End Property

        Public ReadOnly Property ObjectQualifier() As String
            Get
                Return _objectQualifier
            End Get
        End Property

        Public ReadOnly Property DatabaseOwner() As String
            Get
                Return _databaseOwner
            End Get
        End Property

#End Region
        ' general
        Private Function GetNull(ByVal Field As Object) As Object
            Return DotNetNuke.Common.Utilities.Null.GetNull(Field, DBNull.Value)
        End Function


        'Public Overrides Function NTForums_GetSettingsForSession(ByVal ModuleId As Integer) As IDataReader
        '    Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "NTForums_GetSettingsForSession", ModuleId), IDataReader)
        'End Function
        'Public Overrides Function Utility_ExecuteSQL(ByVal SQL As String) As IDataReader
        '    SQL = SQL.Replace("{databaseOwner}", DatabaseOwner)
        '    SQL = SQL.Replace("{objectQualifier}", ObjectQualifier)
        '    Try
        '        Return CType((ConnectionString, CommandType.Text, SQL), IDataReader)

        '    Catch ex As Exception
        '        Return Nothing
        '    End Try

        'End Function
        'Public Overrides Function ActiveForumsCount() As Integer
        '    Dim sSQL As String = "Select Count(*) From " & DatabaseOwner & ObjectQualifier & "NTForums"
        '    Try
        '        Return CType(SqlHelper.ExecuteScalar(ConnectionString, CommandType.Text, sSQL), Integer)

        '    Catch ex As Exception
        '        Return 0
        '    End Try
        'End Function

        'Public Overrides Function GetStatistics(ByVal PortalId As Integer) As Hashtable
        '    Dim statistics As Hashtable = New Hashtable

        '    Dim reader As IDataReader = CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "GetOnlineUserStatistics", PortalId), IDataReader)

        '    If (reader.Read()) Then
        '        statistics.Add("AnonymousUserCount", reader(0))
        '    End If
        '    reader.NextResult()

        '    If (reader.Read()) Then
        '        statistics.Add("OnlineUserCount", reader(0))
        '    End If
        '    reader.NextResult()

        '    If (reader.Read()) Then
        '        statistics.Add("LastUsername", reader(0))
        '        statistics.Add("LastUserId", reader(1))
        '    End If
        '    reader.NextResult()

        '    If (reader.Read()) Then
        '        statistics.Add("MembershipCount", reader(0))
        '    End If
        '    reader.NextResult()

        '    If (reader.Read()) Then
        '        statistics.Add("MembershipToday", reader(0))
        '    End If
        '    reader.NextResult()

        '    If (reader.Read()) Then
        '        statistics.Add("MembershipYesterday", reader(0))
        '    End If

        '    reader.Close()

        '    Return statistics
        'End Function
        ' Forum Stats
        'Public Overrides Function NTForums_GetForumStats(ByVal PortalId As Integer, ByVal ModuleID As Integer) As Hashtable
        '    Dim statistics As Hashtable = New Hashtable

        '    Dim reader As IDataReader = CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "NTForums_GetForumStats", PortalId, ModuleID), IDataReader)

        '    If (reader.Read()) Then
        '        statistics.Add("ActiveUsers", reader(0))
        '    End If
        '    reader.NextResult()

        '    If (reader.Read()) Then
        '        statistics.Add("NewUserID", reader(0))
        '        statistics.Add("NewUserName", reader(1))
        '        statistics.Add("NewUserFirstName", reader(2))
        '        statistics.Add("NewUserLastName", reader(3))
        '    End If
        '    reader.NextResult()

        '    If (reader.Read()) Then
        '        statistics.Add("TotalForums", reader(0))
        '        statistics.Add("TotalTopics", reader(1))
        '        statistics.Add("TotalReplies", reader(2))
        '        statistics.Add("TotalPosts", reader(1) + reader(2))
        '    End If
        '    reader.NextResult()

        '    If (reader.Read()) Then
        '        statistics.Add("TopViewsPostID", reader(0))
        '        statistics.Add("TopViewsForumID", reader(1))
        '        statistics.Add("TopViewsSubject", reader(2))
        '    End If
        '    reader.NextResult()

        '    If (reader.Read()) Then
        '        statistics.Add("TopRepliesPostID", reader(0))
        '        statistics.Add("TopRepliesForumID", reader(1))
        '        statistics.Add("TopRepliesSubject", reader(2))
        '    End If
        '    reader.NextResult()

        '    If (reader.Read()) Then
        '        statistics.Add("MostActivePostID", reader(1))
        '        statistics.Add("MostActiveForumID", reader(2))
        '        statistics.Add("MostActiveSubject", reader(3))
        '    End If

        '    reader.Close()

        '    Return statistics
        'End Function



#Region "Dashboard"
        Public Overrides Function Dashboard_Get(ByVal PortalId As Integer, ByVal ModuleId As Integer) As DataSet
            Return CType(SqlHelper.ExecuteDataset(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_DashBoard_Stats", PortalId, ModuleId), DataSet)
        End Function
#End Region
#Region "Filters"
        Public Overrides Sub Filters_Delete(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal FilterId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Filters_Delete", PortalId, ModuleId, FilterId)
        End Sub
        Public Overrides Sub Filters_DeleteByModuleId(ByVal PortalId As Integer, ByVal ModuleId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Filters_DeleteByModuleId", PortalId, ModuleId)
        End Sub
        Public Overrides Function Filters_Get(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal FilterId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Filters_Get", PortalId, ModuleId, FilterId), IDataReader)
        End Function
        Public Overrides Function Filters_GetEmoticons(ByVal ModuleID As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Filters_GetEmoticons", ModuleID), IDataReader)
        End Function
        Public Overrides Function Filters_List(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal PageIndex As Integer, ByVal PageSize As Integer, ByVal Sort As String, ByVal SortColumn As String) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Filters_List", PortalId, ModuleId, PageIndex, PageSize, Sort, SortColumn), IDataReader)
        End Function
        Public Overrides Function Filters_ListByType(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal FilterType As String) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Filters_ListByType", PortalId, ModuleId, FilterType), IDataReader)
        End Function
        Public Overrides Function Filters_Save(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal FilterId As Integer, ByVal Find As String, ByVal Replace As String, ByVal FilterType As String) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Filters_Save", PortalId, ModuleId, FilterId, Find, Replace, FilterType), Integer)
        End Function


#End Region
#Region "Forums"
        Public Overrides Sub Forums_Delete(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal ForumId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Forums_Delete", PortalId, ModuleId, ForumId)
        End Sub
        Public Overrides Function Forums_Get(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal ForumID As Integer, ByVal UserId As Integer, ByVal WithSecurity As Boolean) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Forums_Get", PortalId, ModuleId, ForumID, UserId, WithSecurity), IDataReader)
        End Function

        Public Overrides Function Forums_List(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal ForumGroupId As Integer, ByVal ParentForumId As Integer, ByVal FillLastPost As Boolean) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Forums_List", ModuleId, ForumGroupId, ParentForumId, FillLastPost), IDataReader)
        End Function
        'Public Overrides Sub Forums_Move(ByVal ModuleId As Integer, ByVal ForumId As Integer, ByVal ForumGroupId As Integer, ByVal SortIndex As Integer)
        '    SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Forums_MoveForum", ModuleId, ForumId, ForumGroupId, SortIndex)
        'End Sub
        Public Overrides Sub Forums_Move(ByVal ModuleId As Integer, ByVal ForumId As Integer, ByVal SortDirection As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Forums_MoveForum", ModuleId, ForumId, SortDirection)
        End Sub
        Public Overrides Function Forum_Save(ByVal PortalId As Integer, ByVal ForumId As Integer, ByVal ModuleId As Integer, ByVal ForumGroupId As Integer, ByVal ParentForumId As Integer, ByVal ForumName As String, ByVal ForumDesc As String, ByVal SortOrder As Integer, ByVal Active As Boolean, ByVal Hidden As Boolean, ByVal ForumSettingsKey As String, ByVal PermissionsId As Integer, ByVal PrefixURL As String, SocialGroupId As Integer, HasProperties As Boolean) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Forum_Save", PortalId, ForumId, ModuleId, ForumGroupId, ParentForumId, ForumName, ForumDesc, SortOrder, Active, Hidden, ForumSettingsKey, PermissionsId, PrefixURL, SocialGroupId, HasProperties), Integer)
        End Function
        
        Public Overrides Sub Forum_ConfigCleanUp(ByVal ModuleId As Integer, ByVal ForumSettingsKey As String, ByVal ForumSecurityKey As String)
            SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Forum_ConfigCleanUp", ModuleId, ForumSettingsKey, ForumSecurityKey)
        End Sub

#End Region
#Region "Groups"
        Public Overrides Sub Groups_Delete(ByVal ModuleID As Integer, ByVal ForumGroupID As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Groups_Delete", ModuleID, ForumGroupID)
        End Sub
        Public Overrides Function Groups_Get(ByVal ModuleId As Integer, ByVal ForumGroupID As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Groups_Get", ModuleId, ForumGroupID), IDataReader)
        End Function
        Public Overrides Function Groups_List(ByVal ModuleId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Groups_List", ModuleId), IDataReader)
        End Function
        Public Overrides Sub Groups_Move(ByVal ModuleId As Integer, ByVal ForumGroupId As Integer, ByVal SortDirection As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Groups_MoveGroup", ModuleId, ForumGroupId, SortDirection)
        End Sub
        Public Overrides Function Groups_Save(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal ForumGroupId As Integer, ByVal GroupName As String, ByVal SortOrder As Integer, ByVal Active As Boolean, ByVal Hidden As Boolean, ByVal PermissionsId As Integer, ByVal PrefixURL As String) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Groups_Save", PortalId, ModuleId, ForumGroupId, GroupName, SortOrder, Active, Hidden, PermissionsId, PrefixURL), Integer)
        End Function

#End Region
#Region "Polls"
        Public Overrides Function Poll_Get(ByVal TopicId As Integer) As DataSet
            Return CType(SqlHelper.ExecuteDataset(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Poll_Get", TopicId), DataSet)
        End Function
        Public Overrides Function Poll_GetResults(ByVal TopicId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Poll_GetResults", TopicId), IDataReader)
        End Function
        Public Overrides Function Poll_HasVoted(ByVal TopicId As Integer, ByVal UserId As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Poll_HasVoted", TopicId, UserId), Integer)
        End Function
        Public Overrides Sub Poll_Option_Save(ByVal PollOptionsId As Integer, ByVal PollId As Integer, ByVal OptionName As String, ByVal TopicId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Poll_Options_Save", PollOptionsId, PollId, OptionName, TopicId)
        End Sub
        Public Overrides Function Poll_Save(ByVal PollId As Integer, ByVal TopicId As Integer, ByVal UserId As Integer, ByVal Question As String, ByVal PollType As String) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Poll_Save", PollId, TopicId, UserId, Question, PollType), Integer)
        End Function
        Public Overrides Sub Poll_Vote(ByVal PollId As Integer, ByVal PollOptionId As Integer, ByVal Response As String, ByVal IPAddress As String, ByVal UserId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Poll_Vote", PollId, PollOptionId, Response, IPAddress, UserId)
        End Sub

#End Region
#Region "Moderation"
        Public Overrides Function Mod_Pending(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal ForumId As Integer, ByVal UserId As Integer) As DataSet
            Return CType(SqlHelper.ExecuteDataset(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Mod_Pending", PortalId, ModuleId, ForumId, UserId), DataSet)
        End Function
        Public Overrides Sub Mod_Reject(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal UserId As Integer, ByVal ForumId As Integer, ByVal TopicId As Integer, ByVal ReplyId As Integer, ByVal Reason As Integer, ByVal Comment As String)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Mod_Reject", PortalId, ModuleId, UserId, ForumId, TopicId, ReplyId, Reason, Comment)
        End Sub

#End Region
#Region "Ranks"
        Public Overrides Sub Ranks_Delete(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal RankId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Ranks_Delete", PortalId, ModuleId, RankId)
        End Sub
        Public Overrides Function Ranks_Get(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal RankId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Ranks_Get", PortalId, ModuleId, RankId), IDataReader)
        End Function
        Public Overrides Function Ranks_List(ByVal PortalId As Integer, ByVal ModuleId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Ranks_List", PortalId, ModuleId), IDataReader)
        End Function
        Public Overrides Function Ranks_Save(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal RankId As Integer, ByVal RankName As String, ByVal MinPosts As Integer, ByVal MaxPosts As Integer, ByVal Display As String) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Ranks_Save", PortalId, ModuleId, RankId, RankName, MinPosts, MaxPosts, Display), Integer)
        End Function

#End Region
#Region "Replies/Comments"
        Public Overrides Function Reply_Get(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal TopicId As Integer, ByVal ReplyId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Reply_Get", PortalId, ModuleId, TopicId, ReplyId), IDataReader)
        End Function
        Public Overrides Function Reply_Save(ByVal PortalId As Integer, ByVal TopicId As Integer, ByVal ReplyId As Integer, ByVal ReplyToId As Integer, ByVal StatusId As Integer, ByVal IsApproved As Boolean, ByVal IsDeleted As Boolean, ByVal Subject As String, ByVal Body As String, ByVal DateCreated As Date, ByVal DateUpdated As Date, ByVal AuthorId As Integer, ByVal AuthorName As String, ByVal IPAddress As String) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Reply_Save", PortalId, TopicId, ReplyId, ReplyToId, StatusId, IsApproved, IsDeleted, Subject, Body, DateCreated, DateUpdated, AuthorId, AuthorName, IPAddress), Integer)
        End Function
        Public Overrides Sub Reply_UpdateStatus(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal TopicId As Integer, ByVal ReplyId As Integer, ByVal UserId As Integer, ByVal StatusId As Integer, ByVal IsMod As Boolean)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Replies_UpdateStatus", PortalId, ModuleId, TopicId, ReplyId, UserId, StatusId, IsMod)
        End Sub
        Public Overrides Sub Reply_Delete(ByVal ForumId As Integer, ByVal TopicId As Integer, ByVal ReplyId As Integer, ByVal DelBehavior As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Reply_Delete", ForumId, TopicId, ReplyId, DelBehavior)
        End Sub

#End Region
#Region "Search"
        Public Overrides Function Search_Standard(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal UserId As Integer, ByVal ForumId As Integer, ByVal IsSuper As Boolean, ByVal RowIndex As Integer, ByVal MaxRows As Integer, ByVal SearchString As String, ByVal MatchType As Integer, ByVal SearchField As Integer, ByVal Timespan As Integer, ByVal AuthorId As Integer, ByVal Author As String, ByVal Forums As String, ByVal Tags As String, ByVal ForumsAllowed As String) As DataSet
            Return SqlHelper.ExecuteDataset(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Search_Standard", PortalId, ModuleId, UserId, ForumId, IsSuper, RowIndex, MaxRows, SearchString, MatchType, SearchField, Timespan, AuthorId, Author, Forums, Tags, ForumsAllowed)
        End Function
        Public Overrides Function Search_DotNetNuke(ByVal ModuleId As Integer) As IDataReader
            Return SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Search_GetSearchItems", ModuleId)
        End Function


        Public Overrides Function Search_FullText(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal UserId As Integer, ByVal ForumId As Integer, ByVal IsSuper As Boolean, ByVal RowIndex As Integer, ByVal MaxRows As Integer, ByVal SearchString As String, ByVal MatchType As Integer, ByVal SearchField As Integer, ByVal Timespan As Integer, ByVal AuthorId As Integer, ByVal Author As String, ByVal Forums As String, ByVal Tags As String, ByVal ForumsAllowed As String) As DataSet
            Return SqlHelper.ExecuteDataset(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Search_FullText", PortalId, ModuleId, UserId, ForumId, IsSuper, RowIndex, MaxRows, SearchString, MatchType, SearchField, Timespan, AuthorId, Author, Forums, Tags, ForumsAllowed)
        End Function
        Public Overrides Function Search_ManageFullText(ByVal Enabled As Boolean) As Integer
            Return Convert.ToInt32(SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Search_ManageFullText", Enabled))
        End Function



#End Region
#Region "Security"
        Public Overrides Sub Security_Delete(ByVal SecuredId As Integer, ByVal ObjectId As Integer, ByVal SecureAction As Integer, ByVal SecureType As Integer, ByVal ObjectType As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Security_Delete", SecuredId, ObjectId, SecureAction, SecureType, ObjectType)
        End Sub
        Public Overrides Function Security_Get(ByVal SecuredId As Integer, ByVal ObjectId As Integer, ByVal SecureType As Integer) As IDataReader
            Return SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Security_Get", SecuredId, ObjectId, SecureType)
        End Function
        Public Overrides Function Security_GetByUser(ByVal PortalId As Integer, ByVal ForumId As Integer, ByVal UserId As Integer, ByVal IsSuperUser As Boolean) As IDataReader
            Return SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Security_GetByUser", PortalId, ForumId, UserId, IsSuperUser)
        End Function
        Public Overrides Sub Security_Save(ByVal SecuredId As Integer, ByVal ObjectId As Integer, ByVal SecureAction As String, ByVal SecureActionValue As Boolean, ByVal SecureType As Integer, ByVal ObjectName As String, ByVal ObjectType As Integer, ByVal SecurityKey As String)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Security_Save", SecuredId, ObjectId, SecureAction, SecureActionValue, SecureType, ObjectName, ObjectType, SecurityKey)
        End Sub
        Public Overrides Function Security_SearchObjects(ByVal PortalId As Integer, ByVal Search As String) As IDataReader
            Return SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Security_SearchObjects", PortalId, Search)
        End Function
        Public Overrides Function Security_GetByKey(ByVal SecurityKey As String) As IDataReader
            Return SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Security_GetByKey", SecurityKey)
        End Function

#End Region
#Region "Settings"

        Public Overrides Sub Settings_Delete(ByVal ModuleId As Integer, ByVal GroupKey As String, ByVal SettingName As String)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Settings_Delete", ModuleId, GroupKey, SettingName)
        End Sub
        Public Overrides Function Settings_Get(ByVal ModuleId As Integer, ByVal GroupKey As String, ByVal SettingName As String) As String
            Return Convert.ToString(SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Settings_Get", ModuleId, GroupKey, SettingName))
        End Function
        Public Overrides Function Settings_List(ByVal ModuleId As Integer, ByVal GroupKey As String) As System.Data.IDataReader
            Return SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Settings_List", ModuleId, GroupKey)
        End Function
        ' KR - grabs all settings for caching
        Public Overrides Function Settings_ListAll(ByVal ModuleId As Integer) As System.Data.IDataReader
            Return SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Settings_ListAll", ModuleId)
        End Function
        Public Overrides Sub Settings_Save(ByVal ModuleId As Integer, ByVal GroupKey As String, ByVal SettingName As String, ByVal SettingValue As String)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Settings_Save", ModuleId, GroupKey, SettingName, SettingValue)
        End Sub
#End Region
#Region "Subscriptions"
        Public Overrides Function Subscriptions_IsSubscribed(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal ForumId As Integer, ByVal TopicId As Integer, ByVal Mode As Integer, ByVal UserId As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Subscriptions_IsSubscribed", PortalId, ModuleId, ForumId, TopicId, Mode, UserId), Integer)
        End Function
        Public Overrides Function Subscriptions_GetDigest(ByVal SubscriptionType As String, ByVal StartDate As Date) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Subscriptions_DigestGet", SubscriptionType, StartDate), IDataReader)
        End Function
        Public Overrides Function Subscriptions_GetSubscribers(ByVal PortalId As Integer, ByVal ForumId As Integer, ByVal TopicId As Integer, ByVal Mode As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Subscriptions_Subscribers", PortalId, ForumId, TopicId, Mode), IDataReader)
        End Function
        Public Overrides Function Subscription_Update(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal ForumId As Integer, ByVal TopicId As Integer, ByVal Mode As Integer, ByVal UserId As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Subscriptions_Update", PortalId, ModuleId, ForumId, TopicId, Mode, UserId), Integer)
        End Function

#End Region
#Region "Tags"
        Public Overrides Sub Tags_Delete(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal TagId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Tags_Delete", PortalId, ModuleId, TagId, -1)
        End Sub
        Public Overrides Sub Tags_DeleteByTopicId(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal TopicId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Tags_Delete", PortalId, ModuleId, -1, TopicId)
        End Sub
        Public Overrides Function Tags_Get(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal TagId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Tags_Get", PortalId, ModuleId, TagId), IDataReader)
        End Function
        Public Overrides Function Tags_List(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal IsCategory As Boolean, ByVal PageIndex As Integer, ByVal PageSize As Integer, ByVal Sort As String, ByVal SortColumn As String, ByVal ForumId As Integer, ByVal ForumGroupId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Tags_List", PortalId, ModuleId, IsCategory, PageIndex, PageSize, Sort, SortColumn, ForumId, ForumGroupId), IDataReader)
        End Function
        Public Overrides Function Tags_Save(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal TagId As Integer, ByVal TagName As String, ByVal Clicks As Integer, ByVal Items As Integer, ByVal Priority As Integer, ByVal TopicId As Integer, ByVal IsCategory As Boolean, ByVal ForumId As Integer, ByVal ForumGroupId As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Tags_Save", PortalId, ModuleId, TagId, TagName, Clicks, Items, Priority, TopicId, IsCategory, ForumId, ForumGroupId), Integer)
        End Function
        Public Overrides Function Tags_Search(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal Search As String) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Tags_Search", PortalId, ModuleId, Search), IDataReader)
        End Function
        Public Overrides Sub Tags_AddTopicToCategory(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal TagId As Integer, ByVal TopicId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Tags_AddTopicToCategory", PortalId, ModuleId, TagId, TopicId)
        End Sub
        Public Overrides Sub Tags_DeleteTopicToCategory(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal TagId As Integer, ByVal TopicId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Tags_DeleteTopicToCategory", PortalId, ModuleId, TagId, TopicId)
        End Sub
#End Region
#Region "Templates"
        Public Overrides Sub Templates_Delete(ByVal TemplateId As Integer, ByVal PortalId As Integer, ByVal ModuleId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Templates_Delete", TemplateId, PortalId, ModuleId)
        End Sub
        Public Overrides Function Templates_Get(ByVal TemplateId As Integer, ByVal PortalId As Integer, ByVal ModuleId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Templates_Get", TemplateId, PortalId, ModuleId), IDataReader)
        End Function
        Public Overrides Function Templates_List(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal TemplateType As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Templates_List", PortalId, ModuleId, TemplateType, 0, 10000), IDataReader)
        End Function
        Public Overrides Function Templates_List(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal TemplateType As Integer, ByVal RowIndex As Integer, ByVal PageSize As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Templates_List", PortalId, ModuleId, TemplateType, RowIndex, PageSize), IDataReader)
        End Function
        Public Overrides Function Templates_Save(ByVal TemplateId As Integer, ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal TemplateType As Integer, ByVal IsSystem As Boolean, ByVal Title As String, ByVal Subject As String, ByVal Template As String) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Templates_Save", TemplateId, PortalId, ModuleId, TemplateType, IsSystem, Title, Subject, Template), Integer)
        End Function
#End Region
#Region "Topics"
        Public Overrides Function Topics_AddRating(ByVal TopicId As Integer, ByVal UserID As Integer, ByVal Rating As Integer, ByVal Comments As String, ByVal IPAddress As String) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Topics_AddRating", TopicId, UserID, Rating, Comments, IPAddress), Integer)
        End Function
        Public Overrides Sub Topics_Delete(ByVal ForumId As Integer, ByVal TopicId As Integer, ByVal DelBehavior As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Topics_Delete", ForumId, TopicId, DelBehavior, True)
        End Sub
        Public Overrides Function Topics_Get(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal TopicId As Integer, ByVal ForumId As Integer, ByVal UserId As Integer, ByVal WithSecurity As Boolean) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Topics_Get", PortalId, ModuleId, TopicId, ForumId, UserId, WithSecurity), IDataReader)
        End Function
        Public Overrides Function Topics_GetRating(ByVal TopicId As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Topics_GetRating", TopicId), Integer)
        End Function
        Public Overrides Function Topics_List(ByVal ForumId As Integer, ByVal PortalId As Integer, ByVal ModuleId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Topics_List", ForumId, PortalId, ModuleId), IDataReader)
        End Function
        Public Overrides Sub Topics_Move(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal ForumId As Integer, ByVal TopicId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Topics_Move", PortalId, ModuleId, ForumId, TopicId)
        End Sub
        Public Overrides Function Topics_Save(ByVal PortalId As Integer, ByVal TopicId As Integer, ByVal ViewCount As Integer, ByVal ReplyCount As Integer, ByVal IsLocked As Boolean, ByVal IsPinned As Boolean, ByVal TopicIcon As String, ByVal StatusId As Integer, ByVal IsApproved As Boolean, ByVal IsDeleted As Boolean, ByVal IsAnnounce As Boolean, ByVal IsArchived As Boolean, ByVal AnnounceStart As Date, ByVal AnnounceEnd As Date, ByVal Subject As String, ByVal Body As String, ByVal Summary As String, ByVal DateCreated As Date, ByVal DateUpdated As Date, ByVal AuthorId As Integer, ByVal AuthorName As String, ByVal IPAddress As String, ByVal TopicType As Integer, ByVal Priority As Integer, ByVal URL As String, ByVal TopicData As String) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Topics_Save", PortalId, TopicId, ViewCount, ReplyCount, IsLocked, IsPinned, TopicIcon, StatusId, IsApproved, IsDeleted, IsAnnounce, IsArchived, GetNull(AnnounceStart), GetNull(AnnounceEnd), Subject, Body, Summary, DateCreated, DateUpdated, AuthorId, AuthorName, IPAddress, TopicType, Priority, URL, TopicData), Integer)
        End Function
        Public Overrides Function Topics_SaveToForum(ByVal ForumId As Integer, ByVal TopicId As Integer, ByVal LastReplyId As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Topics_SaveToForum", ForumId, TopicId, GetNull(LastReplyId)), Integer)
        End Function
        Public Overrides Function Topics_Replies(ByVal TopicId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Topics_Replies", TopicId), IDataReader)
        End Function

        Public Overrides Sub Topics_UpdateStatus(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal TopicId As Integer, ByVal ReplyId As Integer, ByVal TopicStatusId As Integer, ByVal ReplyStatusId As Integer, ByVal UserId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Topics_UpdateStatus", PortalId, ModuleId, TopicId, ReplyId, TopicStatusId, ReplyStatusId, UserId)
        End Sub
#End Region
#Region "UI"
        Public Overrides Function UI_ForumView(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal UserId As Integer, ByVal IsSuper As Boolean, ByVal ForumIds As String) As DataSet
            Return CType(SqlHelper.ExecuteDataset(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_UI_ForumView", PortalId, ModuleId, UserId, IsSuper, -1, ForumIds), DataSet)
        End Function
        Public Overrides Function UI_TopicsView(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal ForumId As Integer, ByVal UserId As Integer, ByVal PageIndex As Integer, ByVal PageSize As Integer, ByVal IsSuper As Boolean, ByVal SortColumn As String) As DataSet
            Return CType(SqlHelper.ExecuteDataset(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_UI_TopicsView", PortalId, ModuleId, ForumId, UserId, PageIndex, PageSize, IsSuper, SortColumn), DataSet)
        End Function
        Public Overrides Function UI_TopicView(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal ForumId As Integer, ByVal TopicId As Integer, ByVal UserId As Integer, ByVal PageIndex As Integer, ByVal PageSize As Integer, ByVal IsSuper As Boolean, ByVal Sort As String) As DataSet
            Return CType(SqlHelper.ExecuteDataset(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_UI_TopicView", PortalId, ModuleId, ForumId, TopicId, UserId, PageIndex, PageSize, IsSuper, Sort), DataSet)
        End Function
        Public Overrides Function UI_NotReadView(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal UserId As Integer, ByVal RowIndex As Integer, ByVal MaxRows As Integer, ByVal Sort As String, ByVal IsSuper As Boolean) As DataSet
            Return CType(SqlHelper.ExecuteDataset(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_UI_NotRead", PortalId, ModuleId, UserId, RowIndex, MaxRows, Sort, IsSuper), DataSet)
        End Function

        Public Overrides Function UI_UnansweredView(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal UserId As Integer, ByVal RowIndex As Integer, ByVal MaxRows As Integer, ByVal Sort As String, ByVal IsSuper As Boolean) As DataSet
            Return CType(SqlHelper.ExecuteDataset(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_UI_UnansweredView", PortalId, ModuleId, UserId, RowIndex, MaxRows, Sort, IsSuper), DataSet)
        End Function
        Public Overrides Function UI_MyTopicsView(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal UserId As Integer, ByVal RowIndex As Integer, ByVal MaxRows As Integer, ByVal Sort As String, ByVal IsSuper As Boolean) As DataSet
            Return CType(SqlHelper.ExecuteDataset(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_UI_MyTopicsView", PortalId, ModuleId, UserId, RowIndex, MaxRows, Sort, IsSuper), DataSet)
        End Function
        Public Overrides Function UI_ActiveView(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal UserId As Integer, ByVal RowIndex As Integer, ByVal MaxRows As Integer, ByVal Sort As String, ByVal IsSuper As Boolean, ByVal TimeFrame As Integer) As DataSet
            Return CType(SqlHelper.ExecuteDataset(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_UI_ActiveView", PortalId, ModuleId, UserId, RowIndex, MaxRows, Sort, IsSuper, TimeFrame), DataSet)
        End Function

#End Region
#Region "UserProfiles"
        Public Overrides Sub Profiles_Create(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal UserId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_UserProfiles_Create", PortalId, -1, UserId)
        End Sub
        Public Overrides Sub Profiles_UpdateActivity(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal UserId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_UserProfiles_UpdateActivity", PortalId, ModuleId, UserId)
        End Sub
        Public Overrides Function Profiles_GetUsersOnline(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal Interval As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_UserProfiles_GetUsersOnline", PortalId, ModuleId, Interval), IDataReader)
        End Function
        Public Overrides Function Profiles_Get(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal UserId As Integer) As DataSet
            Return SqlHelper.ExecuteDataset(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_UserProfiles_Get", PortalId, ModuleId, UserId)
        End Function
        Public Overrides Sub Profiles_Save(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal UserId As Integer, ByVal TopicCount As Integer, ByVal ReplyCount As Integer, ByVal ViewCount As Integer, ByVal AnswerCount As Integer, ByVal RewardPoints As Integer, ByVal UserCaption As String, ByVal Signature As String, ByVal SignatureDisabled As Boolean, ByVal TrustLevel As Integer, ByVal AdminWatch As Boolean, ByVal AttachDisabled As Boolean, ByVal Avatar As String, ByVal AvatarType As Integer, ByVal AvatarDisabled As Boolean, ByVal PrefDefaultSort As String, ByVal PrefDefaultShowReplies As Boolean, ByVal PrefJumpLastPost As Boolean, ByVal PrefTopicSubscribe As Boolean, ByVal PrefSubscriptionType As Integer, ByVal PrefUseAjax As Boolean, ByVal PrefBlockAvatars As Boolean, ByVal PrefBlockSignatures As Boolean, ByVal PrefPageSize As Integer, ByVal Yahoo As String, ByVal MSN As String, ByVal ICQ As String, ByVal AOL As String, ByVal Occupation As String, ByVal Location As String, ByVal Interests As String, ByVal WebSite As String, ByVal Badges As String)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_UserProfiles_Save", PortalId, -1, UserId, TopicCount, ReplyCount, ViewCount, AnswerCount, RewardPoints, UserCaption, Signature, SignatureDisabled, TrustLevel, AdminWatch, AttachDisabled, Avatar, AvatarType, AvatarDisabled, PrefDefaultSort, PrefDefaultShowReplies, PrefJumpLastPost, PrefTopicSubscribe, PrefSubscriptionType, PrefUseAjax, PrefBlockAvatars, PrefBlockSignatures, PrefPageSize, Yahoo, MSN, ICQ, AOL, Occupation, Location, Interests, WebSite, Badges)
        End Sub
        Public Overrides Function Profiles_GetStats(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal Interval As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_UserProfiles_Stats", PortalId, -1, Interval), IDataReader)
        End Function
        Public Overrides Function Profiles_MemberList(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal MaxRows As Integer, ByVal RowIndex As Integer, ByVal Filter As String) As IDataReader
            'Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_UserProfiles_Members", PortalId, MaxRows, RowIndex, Filter), IDataReader)
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_UserProfiles_List", PortalId, -1, MaxRows, RowIndex, Filter), IDataReader)
        End Function



#End Region

#Region "MailQueue"

        Public Overrides Function Queue_List() As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Queue_List"), IDataReader)
        End Function
        Public Overrides Sub Queue_Delete(ByVal EmailId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Queue_DeleteItem", EmailId)
        End Sub
        Public Overrides Sub Queue_Add(ByVal EmailFrom As String, ByVal EmailTo As String, ByVal EmailSubject As String, ByVal EmailBody As String, ByVal EmailBodyPlainText As String, ByVal EmailCC As String, ByVal EmailBCC As String)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Queue_Add", EmailFrom, EmailTo, EmailSubject, EmailBody, EmailBodyPlainText, EmailCC, EmailBCC)
        End Sub

#End Region
#Region "Maintenance"
        Public Overrides Function Forum_Maintenance(ByVal ForumId As Integer, ByVal OlderThanTimeFrame As Integer, ByVal LastActivityTimeFrame As Integer, ByVal ByUserId As Integer, ByVal WithoutReplies As Boolean, ByVal TestRun As Boolean, ByVal DelBehavior As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Forums_Maintenance", ForumId, OlderThanTimeFrame, LastActivityTimeFrame, ByUserId, WithoutReplies, TestRun, DelBehavior), Integer)
        End Function
#End Region

#Region "Utility Items"
        Public Overrides Sub Utility_MarkAllRead(ByVal ModuleId As Integer, ByVal UserId As Integer, ByVal ForumId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Util_MarkAsRead", ModuleId, UserId, ForumId)
        End Sub
        Public Overrides Function Utility_GetFirstUnRead(ByVal TopicId As Integer, ByVal LastReadId As Integer) As Integer
            Return Convert.ToInt32(SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_Util_GetFirstUnread", TopicId, LastReadId))
        End Function
#End Region


#Region "Top Posts"
        Public Overrides Function PortalForums(ByVal PortalId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_TP_PortalForums", PortalId), IDataReader)
        End Function
        Public Overrides Function GetPosts(ByVal PortalId As Integer, ByVal Forums As String, ByVal TopicsOnly As Boolean, ByVal RandomOrder As Boolean, ByVal Rows As Integer, ByVal UserId As Integer, ByVal IgnoreSecurity As Boolean, ByVal IsSuperUser As Boolean, ByVal Tags As String, Optional ByVal FilterByUserId As Integer = -1) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_TP_GetPosts", PortalId, Forums, TopicsOnly, RandomOrder, Rows, UserId, IgnoreSecurity, IsSuperUser, Tags, FilterByUserId), IDataReader)
        End Function
        '
        Public Overrides Function GetPostsByUser(ByVal PortalId As Integer, ByVal Rows As Integer, ByVal IsSuperUser As Boolean, ByVal currentUserId As Integer, ByVal FilteredUserid As Integer, ByVal TopicsOnly As Boolean, ByVal ForumIds As String) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "activeforums_TP_GetByUser", PortalId, Rows, IsSuperUser, currentUserId, FilteredUserid, TopicsOnly, ForumIds), IDataReader)
        End Function
#End Region








    End Class

End Namespace
